// pages/gone/gone.js
var app = getApp()
var currentLocation = "";
Page({
  data: {
    userInfo: {},
    goneList: [],
    couponHidden: true,
    nocancel: false,
    scrollHidden: true,
    remarks: "",
    restaurantName: "",
    restaurantAddress: "",
    restaurantTel: "",
    wishUser: {},
    date:''
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    currentLocation = options.currentLocation;
    var that = this
    app.getUserInfo(function (userInfo) {
      //更新数据
      that.setData({
        userInfo: userInfo
      })
    })
    wx.request({
      url: app.globalData.path + '/weixin/coffee/xcx/coffeePass/history',
      data: {
        userId: that.data.userInfo.userId,
        currentLocation: currentLocation
      },
      method: 'GET',
      success: function (res) {
        console.log(res);
        var goneList = that.data.goneList;
        for (var i = 0; i < res.data.length; i++) {
          goneList.push(res.data[i])
        }
        that.setData({
          goneList: goneList
        })
      }
    })
  },
  onShow: function () {
  
  },
  //地图导航
  openMap: function (e) {
    console.info(e)
    var lat = e.currentTarget.dataset.lat;
    var lng = e.currentTarget.dataset.lng;
    var restaurantName = e.currentTarget.dataset.restaurantname;
    var restaurantAddress = e.currentTarget.dataset.restaurantaddress;
    wx.openLocation({
      latitude: lat,
      longitude: lng,
      scale: 28,
      name: restaurantName,
      address: restaurantAddress
    })
  }
})